<template>
	<view>
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="content">合作学校</block>
		</cu-custom>
		<view class="cu-list menu-avatar" v-for="(item,index) in 6">
			<view class="schoolName">
					<view class="cu-form-group">
						<view class="grid">
							<view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" :data-url="imgList[index]"
							:style="index==0?'border-top: 2px solid rgb(229,229,229)':''">
							 <image :src="imgList[index]" mode="aspectFill"></image>
								<view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
									<text class='cuIcon-close'></text>
								</view>
							</view>
							<view class="solids" @tap="ChooseImage" v-if="imgList.length<4">
								<text class='tb cuIcon-cameraadd'></text>
							</view>
						</view>
					</view>
					<view class="ziti">
						<view class="Name">{{school_name}}</view>
						<view class="sub-title">描述副标题</view>
					</view>
			</view>
		</view>
		<view class="yuanbutton" @tap="add_school()">
			<view class="cf">
				<view class="iconfont icon-tianjia"></view>
			</view>
		</view>
	</view>
</template>

<script>
	const {
		appLogin,httpGet,httpPost} = require("@/utils/common.js")
	export default {
		data() {
			return {
				imgList: [],
				modalName: null,
				textareaAValue: '',
				textareaBValue: '',
				page:'1',
				page_size:'20',
				school_list:[
					{school_name:''},
					{school_name:''}	
				]
			}
		},
		onLoad() {
			appLogin((user_info) => {
				console.log(user_info)
				this.add_school()
			})
		},
		methods: {
			ChooseImage() {
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						if (this.imgList.length != 0) {
							this.imgList = this.imgList.concat(res.tempFilePaths)
						} else {
							this.imgList = res.tempFilePaths
						}
					}
				});
			},
			ViewImage(e) {
				uni.previewImage({
					urls: this.imgList,
					current: e.currentTarget.dataset.url
				});
			},
			DelImg(e) {
				uni.showModal({
					title: '召唤师',
					content: '确定要删除这段回忆吗？',
					cancelText: '再看看',
					confirmText: '再见',
					success: res => {
						if (res.confirm) {
							this.imgList.splice(e.currentTarget.dataset.index, 1)
						}
					}
				})
			},
			add_school(){
				httpGet({
					url:'/api/school/list',
					data:{
						page:this.page,
						page_size:this.page_size,
						school_name:this.school_list.school_name,
						school_id:this.school_list.school_id
					}
				}).then(res => {
					console.log(res)
					return uni.showToast({
						title:"成功",
						icon:'none',
						duration: 2000
					});
				})
			}
		}
	}
</script>

<style>
	page{
		background-color: rgb(255,255,255);
	}
	.cu-list{
		margin-top: 36rpx;
		/* border-top: 2px solid rgb(229,229,229); */
		border-bottom: 2px solid rgb(229,229,229);
	}
	.schoolName{
		display: flex;
		padding-bottom: 13rpx;
		/* height: 145rpx; */
		padding-top: -13rpx;
		margin-top: -15rpx;
		height: 88px;
		width: 375px;
	}
	.solids{
		background-color: rgb(232,232,232);
		width: 130rpx;
		height: 130rpx;
		border: 1px solid rgba(187, 187, 187, 100);
		/* margin-top: 24rpx; */
		/* margin-bottom: 24rpx; */
	}
	.tb{
		line-height: 130rpx;
		display: flex;
		justify-content: center;
	}
	.ziti{
		padding-top: 28rpx;
		margin-left: -4rpx;
	}
	.Name{
		font-size: 36rpx;
		color: rgba(0, 0, 0, 1);
	}
	.sub-title{
		color: rgb(155,155,155);
		font-size: 26rpx;
		padding-top: 13rpx;
	}
	.yuanbutton{
		font-size: 30rpx;
		position: fixed;
		bottom: 82rpx;
		right: 52rpx;
	}
	.cf{
		height: 100rpx;
		width: 100rpx;
		border-radius: 100rpx 100rpx 100rpx 100rpx;
		background-color: rgb(24,144,255);
	}
	.iconfont{
		text-align: center;
		line-height: 100rpx;
		font-size: 70rpx;
		color: rgb(255,255,255);
	}
</style>
